<?php
	/*
	 * update article slug title .
	 *
	*/
	
	
	require_once('../config/constant.php');
	require_once(DAEMONE_HOME . '/lib/lib_database.php');
	require_once(DAEMONE_HOME . '/lib/lib_helper_function.php');
	
	
	set_time_limit(3600);
	$limit = 10000;
	while (TRUE)
	{
		$result = execute_query("select item_id, title from rss_feed_item where title_slug IS NULL or title_slug  = '' limit $limit");

		if($result === FALSE) 
		{
			echo  mysql_error();
		}

		
		if(mysql_num_rows($result) == 0)
		{
			echo "No more records /n";
			exit;
		}
		
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$result_1 = execute_query('update rss_feed_item set title_slug=\''. preg_replace('/[\W]/', '-', $row['title']) .'\' where item_id='.$row['item_id']);
			if($result_1 === FALSE) 
			{
				echo mysql_error(), "\r\n";
			}
			echo 'item_id=', $row['item_id'], "\r\n";
		}
		
	}
	exit;
?>
